package model;

import java.sql.*;
import java.util.Date;
import dal.*;
import util.*;

public class ReceivableModel implements IModel {

	public static class FieldNames {
		public static String Id = "Id";
		public static String IdCompany = "IdCompany";
		public static String IdPhase = "IdPhase";
		public static String PlanDate = "PlanDate";
		public static String RealDate = "RealDate";
		public static String Name = "Name";
		public static String Code = "Code";
		public static String Status = "Status";
		public static String Notification = "Notification";
		public static String Created = "Created";
		public static String Creator = "Creator";
		public static String Updated = "Updated";
		public static String Updator = "Updator";
		public static String Deleted = "Deleted";
		public static String DeletionTime = "DeletionTime";
		public static String IdProject = "IdProject";
		public static String Description = "Description";
		public static String Remark = "Remark";
		public static String ReceivableType = "ReceivableType";
		public static String Money = "Money";
		public static String Currency = "Currency";
	
	}

	public class ErrorMessages {
		public String Id = "";
		public String IdCompany = "";
		public String IdPhase = "";
		public String PlanDate = "";
		public String RealDate = "";
		public String Name = "";
		public String Code = "";
		public String Status = "";
		public String Notification = "";
		public String Created = "";
		public String Creator = "";
		public String Updated = "";
		public String Updator = "";
		public String Deleted = "";
		public String DeletionTime = "";
		public String IdProject = "";
		public String Description = "";
		public String Remark = "";
		public String ReceivableType = "";
		public String Money = "";
		public String Currency = "";
	
	}

    public ErrorMessages errMsgs = new ErrorMessages();

	public String[] errMsgList = null;

// private variables
private int _id = Integer.MIN_VALUE;
private int _id_company = Integer.MIN_VALUE;
private int _id_phase = Integer.MIN_VALUE;
private Date _plan_date = null;
private Date _real_date = null;
private String _name = null;
private String _code = null;
private int _status = Integer.MIN_VALUE;
private int _notification = Integer.MIN_VALUE;
private Date _created = null;
private int _creator = Integer.MIN_VALUE;
private Date _updated = null;
private int _updator = Integer.MIN_VALUE;
private boolean _deleted = false;
private boolean _isdeletedSet = false;
private Date _deletion_time = null;
private int _id_project = Integer.MIN_VALUE;
private String _description = null;
private String _remark = null;
private int _receivable_type = Integer.MIN_VALUE;
private double _money = Double.MAX_VALUE;
private int _currency = Integer.MIN_VALUE;


	public ReceivableModel() {
	}

// get/set
public int getId() {
		return _id;
	}
public void setId(int value) {
		_id = value;
	}
public String getIdToString() {
		if (_id == Integer.MIN_VALUE
				|| _id == Integer.MAX_VALUE) {
			return "";
		} else {
			return Integer.toString(_id);
		}
	}
public int getIdCompany() {
		return _id_company;
	}
public void setIdCompany(int value) {
		_id_company = value;
	}
public String getIdCompanyToString() {
		if (_id_company == Integer.MIN_VALUE
				|| _id_company == Integer.MAX_VALUE) {
			return "";
		} else {
			return Integer.toString(_id_company);
		}
	}
public int getIdPhase() {
		return _id_phase;
	}
public void setIdPhase(int value) {
		_id_phase = value;
	}
public String getIdPhaseToString() {
		if (_id_phase == Integer.MIN_VALUE
				|| _id_phase == Integer.MAX_VALUE) {
			return "";
		} else {
			return Integer.toString(_id_phase);
		}
	}
public Date getPlanDate() {
		return _plan_date;
	}
public void setPlanDate(Date value) {
		_plan_date = value;
	}
public String getPlanDateToString() {
		if (_plan_date != null) {
			return StringUtil.toDateTimeString(_plan_date);
		} else {
			return "";
		}
	}
public Date getRealDate() {
		return _real_date;
	}
public void setRealDate(Date value) {
		_real_date = value;
	}
public String getRealDateToString() {
		if (_real_date != null) {
			return StringUtil.toDateTimeString(_real_date);
		} else {
			return "";
		}
	}
public String getName() {
		return _name;
	}
public void setName(String value) {
		_name = value;
	}
public String getNameToString() {
		if (_name != null) {
			return HtmlUtil.genHtml(_name);
		} else {
			return "";
		}
	}
public String getCode() {
		return _code;
	}
public void setCode(String value) {
		_code = value;
	}
public String getCodeToString() {
		if (_code != null) {
			return HtmlUtil.genHtml(_code);
		} else {
			return "";
		}
	}
public int getStatus() {
		return _status;
	}
public void setStatus(int value) {
		_status = value;
	}
public String getStatusToString() {
		if (_status == Integer.MIN_VALUE
				|| _status == Integer.MAX_VALUE) {
			return "";
		} else {
			return Integer.toString(_status);
		}
	}
public int getNotification() {
		return _notification;
	}
public void setNotification(int value) {
		_notification = value;
	}
public String getNotificationToString() {
		if (_notification == Integer.MIN_VALUE
				|| _notification == Integer.MAX_VALUE) {
			return "";
		} else {
			return Integer.toString(_notification);
		}
	}
public Date getCreated() {
		return _created;
	}
public void setCreated(Date value) {
		_created = value;
	}
public String getCreatedToString() {
		if (_created != null) {
			return StringUtil.toDateTimeString(_created);
		} else {
			return "";
		}
	}
public int getCreator() {
		return _creator;
	}
public void setCreator(int value) {
		_creator = value;
	}
public String getCreatorToString() {
		if (_creator == Integer.MIN_VALUE
				|| _creator == Integer.MAX_VALUE) {
			return "";
		} else {
			return Integer.toString(_creator);
		}
	}
public Date getUpdated() {
		return _updated;
	}
public void setUpdated(Date value) {
		_updated = value;
	}
public String getUpdatedToString() {
		if (_updated != null) {
			return StringUtil.toDateTimeString(_updated);
		} else {
			return "";
		}
	}
public int getUpdator() {
		return _updator;
	}
public void setUpdator(int value) {
		_updator = value;
	}
public String getUpdatorToString() {
		if (_updator == Integer.MIN_VALUE
				|| _updator == Integer.MAX_VALUE) {
			return "";
		} else {
			return Integer.toString(_updator);
		}
	}
public boolean getDeleted() {
		return _deleted;
	}
public void setDeleted(boolean value) {
		_deleted = value;
		_isdeletedSet = true;
	}
public boolean getDeletedSet() {
		return _isdeletedSet;
	}
	public String getDeletedToString() {
		if (_isdeletedSet) {
			return HtmlUtil.genHtml(_deleted);
		} else {
			return "";
		}
	}
public Date getDeletionTime() {
		return _deletion_time;
	}
public void setDeletionTime(Date value) {
		_deletion_time = value;
	}
public String getDeletionTimeToString() {
		if (_deletion_time != null) {
			return StringUtil.toDateTimeString(_deletion_time);
		} else {
			return "";
		}
	}
public int getIdProject() {
		return _id_project;
	}
public void setIdProject(int value) {
		_id_project = value;
	}
public String getIdProjectToString() {
		if (_id_project == Integer.MIN_VALUE
				|| _id_project == Integer.MAX_VALUE) {
			return "";
		} else {
			return Integer.toString(_id_project);
		}
	}
public String getDescription() {
		return _description;
	}
public void setDescription(String value) {
		_description = value;
	}
public String getDescriptionToString() {
		if (_description != null) {
			return HtmlUtil.genHtml(_description);
		} else {
			return "";
		}
	}
public String getRemark() {
		return _remark;
	}
public void setRemark(String value) {
		_remark = value;
	}
public String getRemarkToString() {
		if (_remark != null) {
			return HtmlUtil.genHtml(_remark);
		} else {
			return "";
		}
	}
public int getReceivableType() {
		return _receivable_type;
	}
public void setReceivableType(int value) {
		_receivable_type = value;
	}
public String getReceivableTypeToString() {
		if (_receivable_type == Integer.MIN_VALUE
				|| _receivable_type == Integer.MAX_VALUE) {
			return "";
		} else {
			return Integer.toString(_receivable_type);
		}
	}
public double getMoney() {
		return _money;
	}
public void setMoney(double value) {
		_money = value;
	}
	public String getMoneyToString() {
		if (_money == Double.MIN_VALUE || _money == Double.MAX_VALUE) {
			return "";
		} else {
			return StringUtil.toString(_money);
		}
	}
public int getCurrency() {
		return _currency;
	}
public void setCurrency(int value) {
		_currency = value;
	}
public String getCurrencyToString() {
		if (_currency == Integer.MIN_VALUE
				|| _currency == Integer.MAX_VALUE) {
			return "";
		} else {
			return Integer.toString(_currency);
		}
	}


	@Override
	public int[] getPrimaryKey() {
		int[] ids = new int[1];
		ids[0] = getId();
		return ids;
	}

	@Override
	public IModel readFromResultSet(ResultSet rs) throws SQLException {
		ReceivableModel model = null;

			model = new ReceivableModel();

// read fields
{
				int value = rs.getInt("id");
				if (!rs.wasNull()) {
					model.setId(value);
				}
			}
{
				int value = rs.getInt("id_company");
				if (!rs.wasNull()) {
					model.setIdCompany(value);
				}
			}
{
				int value = rs.getInt("id_phase");
				if (!rs.wasNull()) {
					model.setIdPhase(value);
				}
			}
{
				Date value = rs.getTimestamp("plan_date");
				if (!rs.wasNull()) {
					model.setPlanDate(value);
				}
			}
{
				Date value = rs.getTimestamp("real_date");
				if (!rs.wasNull()) {
					model.setRealDate(value);
				}
			}
{
				String value = rs.getString("name");
				if (!rs.wasNull()) {
					model.setName(value);
				}
			}
{
				String value = rs.getString("code");
				if (!rs.wasNull()) {
					model.setCode(value);
				}
			}
{
				int value = rs.getInt("status");
				if (!rs.wasNull()) {
					model.setStatus(value);
				}
			}
{
				int value = rs.getInt("notification");
				if (!rs.wasNull()) {
					model.setNotification(value);
				}
			}
{
				Date value = rs.getTimestamp("created");
				if (!rs.wasNull()) {
					model.setCreated(value);
				}
			}
{
				int value = rs.getInt("creator");
				if (!rs.wasNull()) {
					model.setCreator(value);
				}
			}
{
				Date value = rs.getTimestamp("updated");
				if (!rs.wasNull()) {
					model.setUpdated(value);
				}
			}
{
				int value = rs.getInt("updator");
				if (!rs.wasNull()) {
					model.setUpdator(value);
				}
			}
{
				boolean value = rs.getBoolean("deleted");
				if (!rs.wasNull()) {
					model.setDeleted(value);
				}
			}
{
				Date value = rs.getTimestamp("deletion_time");
				if (!rs.wasNull()) {
					model.setDeletionTime(value);
				}
			}
{
				int value = rs.getInt("id_project");
				if (!rs.wasNull()) {
					model.setIdProject(value);
				}
			}
{
				String value = rs.getString("description");
				if (!rs.wasNull()) {
					model.setDescription(value);
				}
			}
{
				String value = rs.getString("remark");
				if (!rs.wasNull()) {
					model.setRemark(value);
				}
			}
{
				int value = rs.getInt("receivable_type");
				if (!rs.wasNull()) {
					model.setReceivableType(value);
				}
			}
{
				double value = rs.getDouble("money");
				if (!rs.wasNull()) {
					model.setMoney(value);
				}
			}
{
				int value = rs.getInt("currency");
				if (!rs.wasNull()) {
					model.setCurrency(value);
				}
			}
		

		return model;
	}

	@Override
	public PreparedStatement genSelectStatement(Connection dbConn, IModel query)
			throws SQLException {
		String sql = "SELECT * FROM sp_receivable_select(:id);";
		NamedParameterPreparedStatement st = new NamedParameterPreparedStatement(
				dbConn, sql);

        ReceivableModel obj = (ReceivableModel )query;
		
// set parameters
st.setObject("id", obj.getId());


		return st.getPreparedStatement();
	}

	@Override
	public PreparedStatement genSelectListStatement(Connection dbConn,
			IModelExt query) throws SQLException {
		String sql = "SELECT * FROM sp_receivable_selectList(:limit, :offset, :id,:id_company,:id_phase,:plan_dateFrom,:plan_dateTo,:real_dateFrom,:real_dateTo,:name,:code,:status,:notification,:createdFrom,:createdTo,:creator,:updatedFrom,:updatedTo,:updator,:deleted,:deletion_timeFrom,:deletion_timeTo,:id_project,:description,:remark,:receivable_type,:money,:currency)";

		NamedParameterPreparedStatement st = new NamedParameterPreparedStatement(
				dbConn, sql);

		ReceivableModelExt obj = (ReceivableModelExt) query;

		if (obj.getLimit() != Integer.MIN_VALUE) {
			st.setObject("limit", obj.getLimit());
		}  else {
			st.setObject("limit", Integer.MAX_VALUE);
		}
		if (obj.getOffset() != Integer.MIN_VALUE) {
			st.setObject("offset", obj.getOffset());
		}  else {
			st.setObject("offset", 0);
		}

// set parameters
if (obj.getId() != Integer.MIN_VALUE) {
			st.setObject("id", obj.getId());
		} else {
            st.setObject("id", null);
}
if (obj.getIdCompany() != Integer.MIN_VALUE) {
			st.setObject("id_company", obj.getIdCompany());
		} else {
            st.setObject("id_company", null);
}
if (obj.getIdPhase() != Integer.MIN_VALUE) {
			st.setObject("id_phase", obj.getIdPhase());
		} else {
            st.setObject("id_phase", null);
}
if (obj.getPlanDateFrom() != null) {
			st.setObject("plan_dateFrom", obj.getPlanDateFrom());
		} else {
			st.setObject("plan_dateFrom", null);
		}
		if (obj.getPlanDateTo() != null) {
			st.setObject("plan_dateTo", obj.getPlanDateTo());
		} else {
            st.setObject("plan_dateTo", null);
}
if (obj.getRealDateFrom() != null) {
			st.setObject("real_dateFrom", obj.getRealDateFrom());
		} else {
			st.setObject("real_dateFrom", null);
		}
		if (obj.getRealDateTo() != null) {
			st.setObject("real_dateTo", obj.getRealDateTo());
		} else {
            st.setObject("real_dateTo", null);
}
if (obj.getName() != null) {
			st.setObject("name", obj.getName());
		} else {
            st.setObject("name", null);
}
if (obj.getCode() != null) {
			st.setObject("code", obj.getCode());
		} else {
            st.setObject("code", null);
}
if (obj.getStatus() != Integer.MIN_VALUE) {
			st.setObject("status", obj.getStatus());
		} else {
            st.setObject("status", null);
}
if (obj.getNotification() != Integer.MIN_VALUE) {
			st.setObject("notification", obj.getNotification());
		} else {
            st.setObject("notification", null);
}
if (obj.getCreatedFrom() != null) {
			st.setObject("createdFrom", obj.getCreatedFrom());
		} else {
			st.setObject("createdFrom", null);
		}
		if (obj.getCreatedTo() != null) {
			st.setObject("createdTo", obj.getCreatedTo());
		} else {
            st.setObject("createdTo", null);
}
if (obj.getCreator() != Integer.MIN_VALUE) {
			st.setObject("creator", obj.getCreator());
		} else {
            st.setObject("creator", null);
}
if (obj.getUpdatedFrom() != null) {
			st.setObject("updatedFrom", obj.getUpdatedFrom());
		} else {
			st.setObject("updatedFrom", null);
		}
		if (obj.getUpdatedTo() != null) {
			st.setObject("updatedTo", obj.getUpdatedTo());
		} else {
            st.setObject("updatedTo", null);
}
if (obj.getUpdator() != Integer.MIN_VALUE) {
			st.setObject("updator", obj.getUpdator());
		} else {
            st.setObject("updator", null);
}
		if (obj.getDeletedSet()) {
			st.setObject("deleted", obj.getDeleted());
		} else {
            st.setObject("deleted", null);
}
if (obj.getDeletionTimeFrom() != null) {
			st.setObject("deletion_timeFrom", obj.getDeletionTimeFrom());
		} else {
			st.setObject("deletion_timeFrom", null);
		}
		if (obj.getDeletionTimeTo() != null) {
			st.setObject("deletion_timeTo", obj.getDeletionTimeTo());
		} else {
            st.setObject("deletion_timeTo", null);
}
if (obj.getIdProject() != Integer.MIN_VALUE) {
			st.setObject("id_project", obj.getIdProject());
		} else {
            st.setObject("id_project", null);
}
if (obj.getDescription() != null) {
			st.setObject("description", obj.getDescription());
		} else {
            st.setObject("description", null);
}
if (obj.getRemark() != null) {
			st.setObject("remark", obj.getRemark());
		} else {
            st.setObject("remark", null);
}
if (obj.getReceivableType() != Integer.MIN_VALUE) {
			st.setObject("receivable_type", obj.getReceivableType());
		} else {
            st.setObject("receivable_type", null);
}
if (obj.getMoney() != Double.MAX_VALUE) {
			st.setObject("money", obj.getMoney());
		} else {
            st.setObject("money", null);
}
if (obj.getCurrency() != Integer.MIN_VALUE) {
			st.setObject("currency", obj.getCurrency());
		} else {
            st.setObject("currency", null);
}
	

		return st.getPreparedStatement();
	}

	@Override
	public PreparedStatement genInsertStatement(Connection dbConn, IModel model)
			throws SQLException {
		String sql = "SELECT sp_receivable_insert(:id_company,:id_phase,:plan_date,:real_date,:name,:code,:status,:notification,:creator,:id_project,:description,:remark,:receivable_type,:money,:currency)";
		NamedParameterPreparedStatement st = new NamedParameterPreparedStatement(
				dbConn, sql);

		ReceivableModel obj = (ReceivableModel) model;

		// set parameters here
if (obj.getIdCompany() != Integer.MIN_VALUE) {
			st.setObject("id_company", obj.getIdCompany());
		} else {
			st.setObject("id_company", null);
}
if (obj.getIdPhase() != Integer.MIN_VALUE) {
			st.setObject("id_phase", obj.getIdPhase());
		} else {
			st.setObject("id_phase", null);
}
if (obj.getPlanDate() != null) {
			st.setObject("plan_date", obj.getPlanDate());
		} else {
			st.setObject("plan_date", null);
}
if (obj.getRealDate() != null) {
			st.setObject("real_date", obj.getRealDate());
		} else {
			st.setObject("real_date", null);
}
if (obj.getName() != null) {
			st.setObject("name", obj.getName());
		} else {
			st.setObject("name", null);
}
if (obj.getCode() != null) {
			st.setObject("code", obj.getCode());
		} else {
			st.setObject("code", null);
}
if (obj.getStatus() != Integer.MIN_VALUE) {
			st.setObject("status", obj.getStatus());
		} else {
			st.setObject("status", null);
}
if (obj.getNotification() != Integer.MIN_VALUE) {
			st.setObject("notification", obj.getNotification());
		} else {
			st.setObject("notification", null);
}
if (obj.getCreator() != Integer.MIN_VALUE) {
			st.setObject("creator", obj.getCreator());
		} else {
			st.setObject("creator", null);
}
if (obj.getIdProject() != Integer.MIN_VALUE) {
			st.setObject("id_project", obj.getIdProject());
		} else {
			st.setObject("id_project", null);
}
if (obj.getDescription() != null) {
			st.setObject("description", obj.getDescription());
		} else {
			st.setObject("description", null);
}
if (obj.getRemark() != null) {
			st.setObject("remark", obj.getRemark());
		} else {
			st.setObject("remark", null);
}
if (obj.getReceivableType() != Integer.MIN_VALUE) {
			st.setObject("receivable_type", obj.getReceivableType());
		} else {
			st.setObject("receivable_type", null);
}
if (obj.getMoney() != Double.MAX_VALUE) {
			st.setObject("money", obj.getMoney());
		} else {
			st.setObject("money", null);
}
if (obj.getCurrency() != Integer.MIN_VALUE) {
			st.setObject("currency", obj.getCurrency());
		} else {
			st.setObject("currency", null);
}
	

		return st.getPreparedStatement();
	}

	@Override
	public PreparedStatement genUpdateStatement(Connection dbConn, IModel model)
			throws SQLException {
		String sql = "SELECT sp_receivable_update(:id,:id_company,:id_phase,:plan_date,:real_date,:name,:code,:status,:notification,:updator,:deleted,:deletion_time,:id_project,:description,:remark,:receivable_type,:money,:currency)";

		NamedParameterPreparedStatement st = new NamedParameterPreparedStatement(
				dbConn, sql);

		ReceivableModel obj = (ReceivableModel) model;

		// set parameters here
if (obj.getId() != Integer.MIN_VALUE) {
			st.setObject("id", obj.getId());
		} else {
			st.setObject("id", null);
}
if (obj.getIdCompany() != Integer.MIN_VALUE) {
			st.setObject("id_company", obj.getIdCompany());
		} else {
			st.setObject("id_company", null);
}
if (obj.getIdPhase() != Integer.MIN_VALUE) {
			st.setObject("id_phase", obj.getIdPhase());
		} else {
			st.setObject("id_phase", null);
}
if (obj.getPlanDate() != null) {
			st.setObject("plan_date", obj.getPlanDate());
		} else {
			st.setObject("plan_date", null);
}
if (obj.getRealDate() != null) {
			st.setObject("real_date", obj.getRealDate());
		} else {
			st.setObject("real_date", null);
}
if (obj.getName() != null) {
			st.setObject("name", obj.getName());
		} else {
			st.setObject("name", null);
}
if (obj.getCode() != null) {
			st.setObject("code", obj.getCode());
		} else {
			st.setObject("code", null);
}
if (obj.getStatus() != Integer.MIN_VALUE) {
			st.setObject("status", obj.getStatus());
		} else {
			st.setObject("status", null);
}
if (obj.getNotification() != Integer.MIN_VALUE) {
			st.setObject("notification", obj.getNotification());
		} else {
			st.setObject("notification", null);
}
if (obj.getUpdator() != Integer.MIN_VALUE) {
			st.setObject("updator", obj.getUpdator());
		} else {
			st.setObject("updator", null);
}
		if (obj.getDeletedSet()) {
			st.setObject("deleted", obj.getDeleted());
		} else {
			st.setObject("deleted", null);
}
if (obj.getDeletionTime() != null) {
			st.setObject("deletion_time", obj.getDeletionTime());
		} else {
			st.setObject("deletion_time", null);
}
if (obj.getIdProject() != Integer.MIN_VALUE) {
			st.setObject("id_project", obj.getIdProject());
		} else {
			st.setObject("id_project", null);
}
if (obj.getDescription() != null) {
			st.setObject("description", obj.getDescription());
		} else {
			st.setObject("description", null);
}
if (obj.getRemark() != null) {
			st.setObject("remark", obj.getRemark());
		} else {
			st.setObject("remark", null);
}
if (obj.getReceivableType() != Integer.MIN_VALUE) {
			st.setObject("receivable_type", obj.getReceivableType());
		} else {
			st.setObject("receivable_type", null);
}
if (obj.getMoney() != Double.MAX_VALUE) {
			st.setObject("money", obj.getMoney());
		} else {
			st.setObject("money", null);
}
if (obj.getCurrency() != Integer.MIN_VALUE) {
			st.setObject("currency", obj.getCurrency());
		} else {
			st.setObject("currency", null);
}

	
		return st.getPreparedStatement();
	}

	@Override
	public PreparedStatement genDeleteStatement(Connection dbConn, IModel query)
			throws SQLException {
		String sql = "select sp_receivable_delete(:id);";
		NamedParameterPreparedStatement st = new NamedParameterPreparedStatement(
				dbConn, sql);

        ReceivableModel obj = (ReceivableModel) query;

		// set primary keys
st.setObject("id", obj.getId());


		return st.getPreparedStatement();
	}

	@Override
	public PreparedStatement genCountStatement(Connection dbConn,
			IModelExt input) throws SQLException {
		String sql = "SELECT sp_receivable_count(:id,:id_company,:id_phase,:plan_dateFrom,:plan_dateTo,:real_dateFrom,:real_dateTo,:name,:code,:status,:notification,:createdFrom,:createdTo,:creator,:updatedFrom,:updatedTo,:updator,:deleted,:deletion_timeFrom,:deletion_timeTo,:id_project,:description,:remark,:receivable_type,:money,:currency)";

		NamedParameterPreparedStatement st = new NamedParameterPreparedStatement(
				dbConn, sql);

		ReceivableModelExt obj = (ReceivableModelExt) input;

		// set parameters here
if (obj.getId() != Integer.MIN_VALUE) {
			st.setObject("id", obj.getId());
		} else {
            st.setObject("id", null);
}
if (obj.getIdCompany() != Integer.MIN_VALUE) {
			st.setObject("id_company", obj.getIdCompany());
		} else {
            st.setObject("id_company", null);
}
if (obj.getIdPhase() != Integer.MIN_VALUE) {
			st.setObject("id_phase", obj.getIdPhase());
		} else {
            st.setObject("id_phase", null);
}
if (obj.getPlanDateFrom() != null) {
			st.setObject("plan_dateFrom", obj.getPlanDateFrom());
		} else {
			st.setObject("plan_dateFrom", null);
		}
		if (obj.getPlanDateTo() != null) {
			st.setObject("plan_dateTo", obj.getPlanDateTo());
		} else {
            st.setObject("plan_dateTo", null);
}
if (obj.getRealDateFrom() != null) {
			st.setObject("real_dateFrom", obj.getRealDateFrom());
		} else {
			st.setObject("real_dateFrom", null);
		}
		if (obj.getRealDateTo() != null) {
			st.setObject("real_dateTo", obj.getRealDateTo());
		} else {
            st.setObject("real_dateTo", null);
}
if (obj.getName() != null) {
			st.setObject("name", obj.getName());
		} else {
            st.setObject("name", null);
}
if (obj.getCode() != null) {
			st.setObject("code", obj.getCode());
		} else {
            st.setObject("code", null);
}
if (obj.getStatus() != Integer.MIN_VALUE) {
			st.setObject("status", obj.getStatus());
		} else {
            st.setObject("status", null);
}
if (obj.getNotification() != Integer.MIN_VALUE) {
			st.setObject("notification", obj.getNotification());
		} else {
            st.setObject("notification", null);
}
if (obj.getCreatedFrom() != null) {
			st.setObject("createdFrom", obj.getCreatedFrom());
		} else {
			st.setObject("createdFrom", null);
		}
		if (obj.getCreatedTo() != null) {
			st.setObject("createdTo", obj.getCreatedTo());
		} else {
            st.setObject("createdTo", null);
}
if (obj.getCreator() != Integer.MIN_VALUE) {
			st.setObject("creator", obj.getCreator());
		} else {
            st.setObject("creator", null);
}
if (obj.getUpdatedFrom() != null) {
			st.setObject("updatedFrom", obj.getUpdatedFrom());
		} else {
			st.setObject("updatedFrom", null);
		}
		if (obj.getUpdatedTo() != null) {
			st.setObject("updatedTo", obj.getUpdatedTo());
		} else {
            st.setObject("updatedTo", null);
}
if (obj.getUpdator() != Integer.MIN_VALUE) {
			st.setObject("updator", obj.getUpdator());
		} else {
            st.setObject("updator", null);
}
		if (obj.getDeletedSet()) {
			st.setObject("deleted", obj.getDeleted());
		} else {
            st.setObject("deleted", null);
}
if (obj.getDeletionTimeFrom() != null) {
			st.setObject("deletion_timeFrom", obj.getDeletionTimeFrom());
		} else {
			st.setObject("deletion_timeFrom", null);
		}
		if (obj.getDeletionTimeTo() != null) {
			st.setObject("deletion_timeTo", obj.getDeletionTimeTo());
		} else {
            st.setObject("deletion_timeTo", null);
}
if (obj.getIdProject() != Integer.MIN_VALUE) {
			st.setObject("id_project", obj.getIdProject());
		} else {
            st.setObject("id_project", null);
}
if (obj.getDescription() != null) {
			st.setObject("description", obj.getDescription());
		} else {
            st.setObject("description", null);
}
if (obj.getRemark() != null) {
			st.setObject("remark", obj.getRemark());
		} else {
            st.setObject("remark", null);
}
if (obj.getReceivableType() != Integer.MIN_VALUE) {
			st.setObject("receivable_type", obj.getReceivableType());
		} else {
            st.setObject("receivable_type", null);
}
if (obj.getMoney() != Double.MAX_VALUE) {
			st.setObject("money", obj.getMoney());
		} else {
            st.setObject("money", null);
}
if (obj.getCurrency() != Integer.MIN_VALUE) {
			st.setObject("currency", obj.getCurrency());
		} else {
            st.setObject("currency", null);
}

	
		return st.getPreparedStatement();
	}

/*
	private String fillHtmlTemplate(String template) {
		String html = template
				.replace(":id", Integer.toString(_id))
.replace(":id_company", Integer.toString(_id_company))
.replace(":id_phase", Integer.toString(_id_phase))
.replace(":plan_date", StringUtil.toDateTimeString(_plan_date))
.replace(":real_date", StringUtil.toDateTimeString(_real_date))
.replace(":name", HtmlUtil.genHtml(_name))
.replace(":code", HtmlUtil.genHtml(_code))
.replace(":status", Integer.toString(_status))
.replace(":notification", Integer.toString(_notification))
.replace(":created", StringUtil.toDateTimeString(_created))
.replace(":creator", Integer.toString(_creator))
.replace(":updated", StringUtil.toDateTimeString(_updated))
.replace(":updator", Integer.toString(_updator))
.replace(":deleted", HtmlUtil.genHtml(_isdeletedSet, _deleted))
.replace(":deletion_time", StringUtil.toDateTimeString(_deletion_time))
.replace(":id_project", Integer.toString(_id_project))
.replace(":description", HtmlUtil.genHtml(_description))
.replace(":remark", HtmlUtil.genHtml(_remark))
.replace(":receivable_type", Integer.toString(_receivable_type))
.replace(":money", StringUtil.toString(_money))
.replace(":currency", Integer.toString(_currency))

				;
		return html;
	}
*/

/*
	private String fillHtmlTemplate(String template) {
		String html = template
				.replace(":Id", Integer.toString(_Id))
.replace(":IdCompany", Integer.toString(_IdCompany))
.replace(":IdPhase", Integer.toString(_IdPhase))
.replace(":PlanDate", StringUtil.toDateTimeString(_PlanDate))
.replace(":RealDate", StringUtil.toDateTimeString(_RealDate))
.replace(":Name", HtmlUtil.genHtml(_Name))
.replace(":Code", HtmlUtil.genHtml(_Code))
.replace(":Status", Integer.toString(_Status))
.replace(":Notification", Integer.toString(_Notification))
.replace(":Created", StringUtil.toDateTimeString(_Created))
.replace(":Creator", Integer.toString(_Creator))
.replace(":Updated", StringUtil.toDateTimeString(_Updated))
.replace(":Updator", Integer.toString(_Updator))
.replace(":Deleted", HtmlUtil.genHtml(_isDeletedSet, _Deleted))
.replace(":DeletionTime", StringUtil.toDateTimeString(_DeletionTime))
.replace(":IdProject", Integer.toString(_IdProject))
.replace(":Description", HtmlUtil.genHtml(_Description))
.replace(":Remark", HtmlUtil.genHtml(_Remark))
.replace(":ReceivableType", Integer.toString(_ReceivableType))
.replace(":Money", StringUtil.toString(_Money))
.replace(":Currency", Integer.toString(_Currency))

				;
		return html;
	}
*/

}